﻿using System;
using System.Data;
using System.Collections.Generic;
using Maticsoft.Common;
using lcmyjobs.Model;
namespace lcmyjobs.BLL
{
	/// <summary>
	/// enterprise_interview
	/// </summary>
	public partial class enterprise_interview
	{
		private readonly lcmyjobs.DAL.enterprise_interview dal=new lcmyjobs.DAL.enterprise_interview();
		public enterprise_interview()
		{}

          /// <summary>
        /// 分页获取邀请面试信息列表
        /// </summary>
        /// <param name="enterprise_bid">企业ID</param>
        /// <param name="currentPageIndex">当前页</param>
        /// <param name="pageSize">每页显示条目数</param>
        /// <param name="count">总条目数</param>
        /// <returns>返回的DataSet第2个表是企业名称</returns>
        public DataSet GetInterview(int enterprise_bid, int currentPageIndex, int pageSize, out int count)
        {
            return dal.GetInterview(enterprise_bid,currentPageIndex,pageSize,out count);
        }

        /// <summary>
        /// 通过iid取得面试信息
        /// </summary>
        /// <param name="enterprise_iid"></param>
        /// <returns></returns>
        public DataSet GetInterviewbyiid(string enterprise_iid)
        {
            return dal.GetInterviewbyiid(enterprise_iid);
        }

        /// <summary>
        /// 批量更改信息
        /// </summary>
        /// <param name="keywords">字段名</param>
        /// <param name="value">值</param>
        /// <param name="idlist">主键列表</param>
        /// <returns></returns>
        public bool UpdateWhere(string keywords, string value, string idlist)
        {
            return dal.UpdateWhere(keywords, value, idlist);
        }
		#region  Method

		/// <summary>
		/// 得到最大ID
		/// </summary>
		public int GetMaxId()
		{
			return dal.GetMaxId();
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int enterprise_iid)
		{
			return dal.Exists(enterprise_iid);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int  Add(lcmyjobs.Model.enterprise_interview model)
		{
			return dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(lcmyjobs.Model.enterprise_interview model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int enterprise_iid)
		{
			
			return dal.Delete(enterprise_iid);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string enterprise_iidlist )
		{
			return dal.DeleteList(enterprise_iidlist );
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public lcmyjobs.Model.enterprise_interview GetModel(int enterprise_iid)
		{
			
			return dal.GetModel(enterprise_iid);
		}

		/// <summary>
		/// 得到一个对象实体，从缓存中
		/// </summary>
		public lcmyjobs.Model.enterprise_interview GetModelByCache(int enterprise_iid)
		{
			
			string CacheKey = "enterprise_interviewModel-" + enterprise_iid;
			object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
			if (objModel == null)
			{
				try
				{
					objModel = dal.GetModel(enterprise_iid);
					if (objModel != null)
					{
						int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
						Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
					}
				}
				catch{}
			}
			return (lcmyjobs.Model.enterprise_interview)objModel;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			return dal.GetList(Top,strWhere,filedOrder);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<lcmyjobs.Model.enterprise_interview> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<lcmyjobs.Model.enterprise_interview> DataTableToList(DataTable dt)
		{
			List<lcmyjobs.Model.enterprise_interview> modelList = new List<lcmyjobs.Model.enterprise_interview>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				lcmyjobs.Model.enterprise_interview model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new lcmyjobs.Model.enterprise_interview();
					if(dt.Rows[n]["enterprise_iid"]!=null && dt.Rows[n]["enterprise_iid"].ToString()!="")
					{
						model.enterprise_iid=int.Parse(dt.Rows[n]["enterprise_iid"].ToString());
					}
					if(dt.Rows[n]["enterprise_bid"]!=null && dt.Rows[n]["enterprise_bid"].ToString()!="")
					{
						model.enterprise_bid=int.Parse(dt.Rows[n]["enterprise_bid"].ToString());
					}
					if(dt.Rows[n]["enterprise_rid"]!=null && dt.Rows[n]["enterprise_rid"].ToString()!="")
					{
						model.enterprise_rid=int.Parse(dt.Rows[n]["enterprise_rid"].ToString());
					}
					if(dt.Rows[n]["uid"]!=null && dt.Rows[n]["uid"].ToString()!="")
					{
						model.uid=int.Parse(dt.Rows[n]["uid"].ToString());
					}
					if(dt.Rows[n]["interviewtime"]!=null && dt.Rows[n]["interviewtime"].ToString()!="")
					{
						model.interviewtime=DateTime.Parse(dt.Rows[n]["interviewtime"].ToString());
					}
					if(dt.Rows[n]["interviewexp"]!=null && dt.Rows[n]["interviewexp"].ToString()!="")
					{
					model.interviewexp=dt.Rows[n]["interviewexp"].ToString();
					}
					if(dt.Rows[n]["isuserbrower"]!=null && dt.Rows[n]["isuserbrower"].ToString()!="")
					{
						if((dt.Rows[n]["isuserbrower"].ToString()=="1")||(dt.Rows[n]["isuserbrower"].ToString().ToLower()=="true"))
						{
						model.isuserbrower=true;
						}
						else
						{
							model.isuserbrower=false;
						}
					}
					if(dt.Rows[n]["issuccess"]!=null && dt.Rows[n]["issuccess"].ToString()!="")
					{
						if((dt.Rows[n]["issuccess"].ToString()=="1")||(dt.Rows[n]["issuccess"].ToString().ToLower()=="true"))
						{
						model.issuccess=true;
						}
						else
						{
							model.issuccess=false;
						}
					}
					if(dt.Rows[n]["iscome"]!=null && dt.Rows[n]["iscome"].ToString()!="")
					{
						if((dt.Rows[n]["iscome"].ToString()=="1")||(dt.Rows[n]["iscome"].ToString().ToLower()=="true"))
						{
						model.iscome=true;
						}
						else
						{
							model.iscome=false;
						}
					}
					if(dt.Rows[n]["toldtime"]!=null && dt.Rows[n]["toldtime"].ToString()!="")
					{
						model.toldtime=DateTime.Parse(dt.Rows[n]["toldtime"].ToString());
					}
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  Method
	}
}

